<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../../../common/js/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="../../../../common/js/bootstrap-3.3.7-dist/css/bootstrap-theme.css" />
		<script src="../../../js/jquery-2.2.3.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../../../js/webuploader-0.1.5/webuploader.css" />
		<script src="../../../js/webuploader-0.1.5/webuploader.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../../../css/store_member/style.css" />
		<link rel="stylesheet" type="text/css" href="../../../css/title.css" />
		<style type="text/css">
			.container-fluid {
				padding: 0;
				margin-top: 0.263888rem;
				border-top: 0.013888rem solid #CCCCCC;
			}
			
			#fx {
				padding: 0 0.555555rem;
				border-top: 0.013888rem solid #CCCCCC;
			}
			
			.container-fluid .fz {
				margin-top: 0;
				padding: 0 0.555555rem;
				width: 100%;
				box-shadow: 0.069444rem 0.069444rem 0.069444rem #b3b3b3;
				margin-bottom: 0.069444rem;
			}
			
			.vip_img {
				padding-bottom: 0.694444rem;
				box-shadow: 0.069444rem 0.069444rem 0.069444rem #b3b3b3;
			}
			
			.vip_img .vip_div {
				margin: 0 auto;
				position: relative;
				width: 2.152777rem;
				height: 2.152777rem;
				border-radius: 100%;
				overflow: hidden;
				background: #E9303E;
			}
			
			.vip_img .vip_div img {
				width: 100%;
				height: 100%;
				position: absolute;
				left: 0;
				top: 0;
				z-index: 10;
			}
			
			.vip_img>a {
				width: 2rem;
				padding: 0.12rem 0.25rem;
				border: none;
			}
			
			.vip_img>p {
				margin-top: 0.236111rem;
				margin-left: 0.381rem;
			}
			
			.edit {
				width: 100%;
				height: 0.5777rem;
				line-height: 0.5777rem;
				font-size: 0.1388rem;
				text-align: center;
				background: rgba(132, 132, 132, 0.8);
				position: absolute;
				bottom: 0;
				left: 0;
				z-index: 10;
				color: white;
			}
			
			.edit input {
				width: 100%;
				height: 0.5777rem;
				position: absolute;
				bottom: 0;
				left: 0;
				z-index: 25;
				opacity: 0;
			}
			
			.add_btn {
				background: #E9303E;
			}
			
			.img_header {
				/*background: #E9303E;*/
			}
			
			.webuploader-pick {
				position: relative;
				display: inline-block;
				cursor: pointer;
				background: rgba(132, 132, 132, 0.8);
				padding: 0;
				color: #fff;
				text-align: center;
				border-radius: 3px;
				overflow: hidden;
			}
		</style>
		<script src="../../../js/jquery-2.2.3.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../../../common/js/bootstrap-3.3.7-dist/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>

	</head>

	<body style="background-color: white;">
		<div class="header">
			<a class="glyphicon glyphicon-menu-left f28 col-xs-4" href="javascript:history.go(-1)" style="text-align: left;"></a>
			<!--<span class="f28 col-xs-4" style="text-align: center;">会员认证</span>-->
		</div>
		<div class="vip_img" id="vip_ren">
			<div class="vip_div">
				<img class="img_header" src="../../../images/coalltion/touxiang.png" />
				<!--<div class="edit">					
					<span>编辑			
					</span>
					<input type="file" name="image" id="image" accept="image/x-png" onchange="test()" />
				</div>-->
				<div id="uploader" class="wu-example edit">
					<div id="thelist" class="uploader-list"></div>
					<div class="btns">
						<div id="picker">编辑</div>
					</div>
				</div>
			</div>
			<p>
				<span class="f24" id="f24"></span>
				<img style="height: 0.333333rem;margin-left:0.333333rem;" id="vipImg" src="../../../images/store/store/ionc/vip.png" />
			</p>
			<p></p>
			<!--<a href="../../personage/person_MakerApplyVip.html" class="f28_s add_btn">会员认证</a>
			<p>剩余时间: 7天</p>-->
		</div>
		<div class="container-fluid">
			<div class="fz">
				<p style="padding: 0.416666rem 0px;margin: 0;">
					<span class="f30" style="color: red;">会员特权</span>
					<img src="../../../images/store/store/ionc/duihuan.png" style="height: 0.333333rem;margin-left: 0.416666rem;" />
					<span class="f24" style="color: #333333;">金币兑换
						<img src="../../../images/store/tixian.png" style="height: 0.333333rem;margin-left: 0.416666rem;"/>
						<span class="f24" style="color: #333333;">仁和币提现</span>
				</p>
			</div>
			<div style="height: 0.277777rem;background-color: #F7F7F7;">
			</div>
			<p id="fx" class="f30" style="color: red;padding-top: 0.277777rem;">认证须知</p>
			<p class="" style="padding: 0 0.555555rem;">巴拉巴拉</p>
		</div>
	</body>
	<script src="../../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var tokenReztApp = $.cookie("tokenReztApp");
		if(!tokenReztApp) {
			window.location.href = "../../login/login/login.html";
		}
		$(function() {
			currentyf();
		});

		//用户信息
		var user, role, goodsId;
		//获取当前会员信息
		function currentyf() {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109/member-service/auth/current?token=" + tokenReztApp,
				dataType: "JSON",
				async: false,
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					$.removeCookie('tokenReztApp', {
						expires: 7,
						path: '/'
					});
					$.removeCookie("tokenRh", {
						expires: 7,
						path: '/'
					});
					$.removeCookie('memberId', {
						expires: 7,
						path: '/'
					});
					$.removeCookie('roleId', {
						expires: 7,
						path: '/'
					});
					window.location.href = "../../login/login/login.html";
				},
				success: function(data) {
					user = data.loginName;
					role = data.roleList[0].id; //角色
					goodsId = data.id;
				}
			});
		}
		
		//时间戳转化
		function fmtDate(obj) {
			var date = new Date(obj);
			var y = 1900 + date.getYear();
			var m = "0" + (date.getMonth() + 1);
			var d = "0" + date.getDate();
			return y + "/" + m.substring(m.length - 2, m.length) + "/" + d.substring(d.length - 2, d.length);
		}
		//第一张
		var uploader = WebUploader.create({
			auto: true, //true，选择文件后立即上传，false，选择文件后先进入文件队列
			swf: 'webuploader-0.1.5/Uploader.swf',
			server: 'http://47.104.13.109/attachment-service/tfAttachment',
			pick: '#picker',
			compress: {
				width: 1080,
				height: 500,
				quality: 90,
				allowMagnify: false,
				crop: true,
				preserveHeaders: true,
				noCompressIfLarger: false,
				compressSize: 1,
				sendAsBinary: true
			},
			fileSingleSizeLimit: 2 * 1024 * 1024,
			accept: {
				title: 'Images',
				extensions: 'jpg,jpeg,bmp,png',
				mimeTypes: 'image/jpeg,image/bmp,image/png'
			},
			duplicate: true,
		});
		uploader.on('error', function(type) {
			layer.msg("图片过大，请按要求大小上传图片");
		});
		uploader.on('uploadSuccess', function(file, response) {
			var s = response._raw;
			var pic1 = "http://oxjfr3ifx.bkt.clouddn.com/" + s;
			$(".img_header").attr("src", pic1);
			//上传图片到我的信息
			$.ajax({
				type: "get",
				url: "http://47.104.13.109/member-service/member/mine/member?token=" + $.cookie("tokenRh"),
				async: true,
				success: function(res) {
					var birthday = fmtDate(res.birthday);
					if(birthday == '') {
						birthday = "1900/01/01"
					} else {
						birthday = fmtDate(res.birthday);
					}
					$.ajax({
						type: "get",
						url: "http://47.104.13.109/member-service/member/mine/member",
						async: true,
						data: {
							token: $.cookie("tokenRh"),
							avatar: s,
							gender: res.gender,
							birthday: birthday,
							industry: res.industry,
							profession: res.profession,
							hobby: res.hobby,
							address: res.address
						},
						success: function(res1) {
							console.log(res1)
						}
					});
				},
				error: function(error) {
					console.log(error)
				}
			});

		});
		$.ajax({
			type: "get",
			url: "http://47.104.13.109/member-service/member/mine/member?token=" + $.cookie("tokenRh"),
			async: true,
			success: function(data) {
				//					console.log(data);
				$("#f24").html(data.loginName)
				if(data.avatar != '') {
					$(".img_header").attr("src", 'http://oxjfr3ifx.bkt.clouddn.com/' + data.avatar);
				}
				for(var i = 0; i < data.roleList.length; i++) {
					if(data.roleList[i].id == 'f1' || data.roleList[i].id == 'f2') {
						//计算剩余时间
						var startTime = data.roleList[i].updateDate; //标记：会员截至时间
						var s1 = new Date(startTime),
							s2 = new Date(),
							runTime = parseInt((s2.getTime() - s1.getTime()) / 1000);
						runTime = runTime % (86400 * 30);
						var day = Math.floor(runTime / 86400);
						if(data.roleList[i].id == 'f1') {
							$("#vipImg").attr("src", "../../../images/store/vipdianliang.png");
						} else {
							$("#vipImg").attr("src", "../../../images/store/vipdianliang.png"); //标记
						}
						str = '<a href="../../personage/person_MakerApplyVip.html" class="f28_s add_btn">会员续费</a><p>期限: ' + fmtDate(data.roleList[1].deadline) + '</p>'
					} else {
						$.ajax({
							type: "get",
							url: "http://47.104.13.109:80/applyfor-service/founder/searchUserType?applyforUser=" + data.loginName + "&type=0",
							async: false,
							success: function(res) {
								console.log(res)
								if(res.auditStatus == '0') {
									$("#vipImg").attr("src", "../../../images/store/vip.png");
									str = '<a href="#" class="f28_s add_btn">审核中</a>'

								} else {
									$("#vipImg").attr("src", "../../../images/store/vip.png");
									str = '<a href="../../personage/person_MakerApplyVip.html" class="f28_s add_btn">会员认证</a>'
								}
							}
						});

					}
				}
				$("#vip_ren").append(str)
			}
		});
	</script>

</html>